using Domain.Dto;
using Gmmy.DomainExtension;
using System;
using System.Linq.Expressions;

namespace Domain.Specification
{
    public class ModuleListSpecification : Specification<ModuleListInput>
    {
        public Guid? FId { get; set; }
        public string ModuleName { get; set; }
        public int? Sort { get; set; }


        public ModuleListSpecification(ModuleListInput input)
        {
            FId = input.FId;
            ModuleName = input.ModuleName;
            Sort = input.Sort;

        }

		/// <summary>
        /// 查询规约
        /// </summary>
        /// <returns></returns>
        public override Expression<Func<ModuleListInput, bool>> SatisfiedBy()
        {
            var where = PredicateBuilder.True<ModuleListInput>().And(x => !x.IsDeleted);
            if (FId != null)
            {
                where = where.And(x => x.FId == FId);
            }
            if (!string.IsNullOrEmpty(ModuleName))
            {
                where = where.And(x => x.ModuleName.Contains(ModuleName));
            }
            if (Sort != null)
            {
                where = where.And(x => x.Sort == Sort);
            }

            return where;
        }
    }
}
